home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 10
/
The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso
/
PC_SIGCD
/
26
/
3
/
DISK2631.ZIP
/
EXAMP1.ZIP
/
RMEX079.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-03-28
|
953b
|
30 lines
'Reference Manual Example Page 79
CLS
'Set up trap for processing COM input
ON COM(1) GOSUB GetComInput
'Allocate a 5K array to store input
DIM ComPortInput$( 5*1024 )
'Allocate head and tail pointers
HeadPtr% = 0 : TailPtr% = 0
COM(1) ON 'turn COM input trapping on
$COM 1024 'set up 1K input buffer
OPEN "COM1:" AS #1 'open COM1 with all default settings
PRINT "Press any key to terminate the program..."
WHILE NOT INSTAT 'if buffer isn't empty, display input
IF TailPtr% <> HeadPtr% THEN
PRINT "COM Port input: "; COMPortInput$( TailPtr% )
TailPtr% = TailPtr% + 1 'step to next spot in buffer
END IF
LOCATE 2,1 : PRINT TIME$
WEND
CLOSE
END
'Routine to COM port interrupt
GetCOMInput:
'Read a line of input from COM port buffer
INPUT #1, COMPortInput$(HeadPtr%)
HeadPtr% = HeadPtr% + 1 'advance buffer pointer
RETURN